<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8"/>
    <title>批量提交订单</title>
    <script th:src="@{/js/jquery-1.8.3.js}"></script>
    <script type="text/javascript">
    function test() {
        var params={
            name:"zhs",
            password:"123456"
        };
    $.ajax({
            type: "Post",
            url: "/hello",
            data:JSON.stringify(params),
            contentType: "application/json; charset=utf-8",
            dataType:"json",
            success: function(data) {
                alert(data.name);
            },
            error: function(err) {
                alert("失败");
            }
    });}
function check() {
    if($("input[name='MerchantID']").val()==""){
        alert("商家编号不能为空");
        return false;
    }
    else if($("input[name='ProductID']").val()==""){
        alert("商品编号不能为空");
        return false;
    }
    else if($("input[name='BuyAmount']").val()==""){
        alert("充值数量不能为空");
        return false;
    }
    else if($("input[name='Key']").val()==""){
        alert("商家密钥不能为空");
        return false;
    }
    else if($(" input[name='file'] ").val()==""){
        alert("文件没有选中");
        return false;
    }else {
        return true;
    }
}
    </script>
</head>
<body>
<p>
<form method="POST" action="#" th:action="@{/buy}" th:object="${buy}" enctype="multipart/form-data" onsubmit="return check()">
<p>
     <input type="text" name="ProductID" th:field="*{name}" style="display:none"/>
    商品编号: <input type="text" name="ProductID" th:field="*{ProductID}"/>
    充值数量: <input type="text" name="BuyAmount" th:field="*{BuyAmount}"/>
</p>
    <p>
        号码文件：<input type="file" name="file" id="file"/><br/>
    </p>
        <p>

        </p>
        <p>
            <input type="reset"  value="取消"/>
            <input type="submit" value="提交"/>
        </p>
</form>

</p>

<table border="1" cellspacing="0" width="700">
    <tr align="center">
        <th>充值账号</th>
        <th>充值数量</th>
        <th>提交结果</th>
    </tr>
    <tr align="center" th:each="al : ${arrayList}">
        <td th:text="${al.account}">${al.account}</td>
        <td th:text="${al.amount}">${al.amount}</td>
        <td th:text="${al.result}">${al.result}</td>
    </tr>
</table>
</body>
</html>